package com.lft09.daemon;

/**
 * Function: 		A {@code TestDaemon} 测试守护线程。<br/>
 * Reason:   		ADD REASON.<br/>
 * Date:            2021-01-27 20:08<br/>
 * <p>
 * Class Name:      TestDaemon<br/>
 * Package Name:    com.lft09.daemon<br/>
 * @author Laifengting / E-mail:laifengting@foxmail.com
 * @version 1.0.0
 * @since JDK 8
 */
public class TestDaemon {
	public static void main(String[] args) {
		God god = new God();
		People people = new People();
		
		Thread t1 = new Thread(god);
		// 默认是 false 表示是用户线程。正常线程都是用户线程。
		t1.setDaemon(true);
		t1.start();
		
		new Thread(people).start();
		
	}
}

/**
 * 上帝
 */
class God implements Runnable {
	
	@Override
	public void run() {
		while (true) {
			System.out.println("上帝保佑着");
		}
	}
}

/**
 * 人类
 */
class People implements Runnable {
	@Override
	public void run() {
		for (int i = 0; i < 36500; i++) {
			System.out.println("一生都开心的活动。");
		}
		System.out.println("-========Goodbye World!========-");
	}
}
